package nckd.wnqjt.tmc.tda.plugin.form;

import kd.bos.algo.DataSet;
import kd.bos.entity.report.AbstractReportListDataPlugin;
import kd.bos.entity.report.ReportQueryParam;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.QueryServiceHelper;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author zhujintao
 * @date 2024/11/05
 * @desc  账户分布
 */
public class AccountDistributionDetailListDataPlugin extends AbstractReportListDataPlugin {

    @Override
    public DataSet query(ReportQueryParam reportQueryParam, Object o) throws Throwable {
        //QFilter accountQfilter = new QFilter("bank.finorgtype.number", QCP.not_equals, "FI-015").and("acctstatus", QCP.not_equals, "closed");
        //筛选出 筛选器传入的ids
        Map<String, Object> customParam = reportQueryParam.getCustomParam();
        List<String> list = (ArrayList<String>) customParam.get("id");
        List<Long> longList = list.stream().map(e -> Long.valueOf(e)).collect(Collectors.toList());
        QFilter accountQfilter = new QFilter("id", QCP.in, longList);
        String amAccountbankSelectField = "id,company.id companyid,company.number companynumber,company.name companyname" +
                ",acctproperty.id acctpropertyid,acctproperty.number acctpropertynumber,acctproperty.name acctpropertyname,bankaccountnumber,opendate" +
                ",bank.id bankid,bank.number banknumber,bank.name bankname,bank.bank_cate.id bankbankcateid,bank.bank_cate.number bankbankcatenumber,bank.bank_cate.name bankbankcatename";
        DataSet beiBankbalanceSubsidiaryDataSet = QueryServiceHelper.queryDataSet(this.getClass().getName(), "am_accountbank", amAccountbankSelectField, accountQfilter.toArray(), null);
        return beiBankbalanceSubsidiaryDataSet;
    }
}